package org.yray.ttmq.controler;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.yray.ttmq.MqttInitialized;

import javax.annotation.Resource;

@RestController
@RequestMapping("a")
@Slf4j
public class MqttController {

    @Resource
    private MqttInitialized mqttInitialized;


    @GetMapping("b")
    public void receive(@RequestParam(value = "message") String message) throws MqttException {
        mqttInitialized.subscribe("stock", 2); //订阅
        mqttInitialized.publish("stock", message, 2);//发布
        //  mqttImpl.MqttCallBack();
    }
}

